using System;
using System.Collections.Generic;
using System.ServiceModel.DomainServices.Client;
using jSLApp.Web;
using jSLCore.Client.Presentation.BaseControl;

namespace jSLApp.Client
{
    public static class Communication
    {
        public static void DoWorkOnOperation<TResult>(this DataControl dataControl, string screenText, Func<MainDomainContext, InvokeOperation<TResult>> operation, Action<bool, TResult> onCompleted, MainDomainContext domanService = null)
        {
            dataControl.DoWorkOnOperation(screenText, operation, onCompleted, domanService);
        }

        public static void DoWorkOnVoidOperation(this DataControl dataControl, string screenText, Func<MainDomainContext, InvokeOperation> operation, Action<bool> onCompleted, MainDomainContext domanService = null)
        {
            dataControl.DoWorkOnVoidOperation(screenText, operation, onCompleted, domanService);
        }

        public static void DoWorkOnQuery<TResult>(this DataControl dataControl, string screenText, Func<MainDomainContext, EntityQuery<TResult>> query, Action<bool, IEnumerable<TResult>> onCompleted, MainDomainContext domainService = null)
            where TResult : Entity
        {
            dataControl.DoWorkOnQuery(screenText, query, onCompleted, domainService);
        }

        public static void DoWorkOnSingle<TResult>(this DataControl dataControl, string screenText, Func<MainDomainContext, EntityQuery<TResult>> query, Action<bool, TResult> onCompleted, MainDomainContext domainService = null)
            where TResult : Entity
        {
            dataControl.DoWorkOnSingle(screenText, query, onCompleted, domainService);
        }
    }
}